#!/bin/bash

showdirs(){
	dirlist=`dirs -l`
	index=0
	for tr in $dirlist
	do
		echo "($index) $tr"
		index=`expr $index + 1 `
	done
}

skiptop(){
	shift 1
	echo $*
}



echo -----$1


if [ ! "$1" = "" ];then
	popd +$1 1>/dev/null
else
	index=`showdirs | awk '{print $1}' | sed "s/[(]//" | sed "s/[)]//"`
	index=`skiptop $index`	

	ct=0
	for tr in $index
	do
		tr=`expr $tr - $ct `
		popd +$tr 1>/dev/null
		ct=`expr $ct + 1 `
	done
fi

showdirs
